﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace SuperX.Common
{
    // 
    public class ThreadRegisterManager
    {
        // 
        public static void Register()
        {
            ThreadRegisterManager._threadRegisterDic.TryAdd(Thread.CurrentThread.ManagedThreadId, null);
        }

        // 
        public static void UnRegister()
        {
            object obj;
            ThreadRegisterManager._threadRegisterDic.TryRemove(Thread.CurrentThread.ManagedThreadId, out obj);
        }

        // 
        public static bool HasRegister()
        {
            return ThreadRegisterManager._threadRegisterDic.ContainsKey(Thread.CurrentThread.ManagedThreadId);
        }

        // 
        public static void Clear()
        {
            ThreadRegisterManager._threadRegisterDic.Clear();
        }

        // 
        private static ConcurrentDictionary<int, object> _threadRegisterDic = new ConcurrentDictionary<int, object>();
    }
}
